//面包屑
new Vue().$mount('#crumbs');
var vue = new Vue({
    el: "#msgdetail",
    data:{

            msgDetail: {
                msgId: localStorage.getItem("receivedMsgId")
            },
            content:"",
            hasConfirm:0,
            replys:[],
            pageIndex:1,
            pageSize:10,
            total:25
    },
    methods:{
        //从服务器读取数据
        initData: function(){
            VanyAjax("receivedMessageList/getMsgDetail?msgId="+this.msgDetail.msgId,{},"GET",this.$el).done(function (data) {
                vue.msgDetail=data;
                if( vue.msgDetail.isConfirm==='1')
                {
                    VanyAjax("/receivedMessageList/getReceiptRecordByMsgIdAndStatus",{msgId:vue.msgDetail.msgId,receiptSatus:'2'},"GET",this.$el).done(function (data) {
                        if (data!=null)
                        {
                            vue.hasConfirm=1;
                        }
                        else
                        {
                            vue.hasConfirm=0;
                        }
                    },false)
                }
            },false)

            VanyAjax("receivedMessageList/getReplies?msgId="+this.msgDetail.msgId,{scrollPageSize:this.pageSize ,scrollPageIndex:this.pageIndex},"GET",this.$el).done(function (data) {
                vue.replys=data.rows;
                vue.total=data.total;
            },false)

        },
        loadData:function () {
            VanyAjax("receivedMessageList/getReplies?msgId="+this.msgDetail.msgId,{scrollPageSize:this.pageSize ,scrollPageIndex:this.pageIndex},"GET",this.$el).done(function (data) {
                this.replys=data.rows;
                this.total=data.total;
            },false)
        },
        //每页显示数据量变更
        handleSizeChange: function(val) {
            vue.pageSize = val;
            vue.loadData(this.pageIndex, this.pageSize);
        },
        //页码变更
        handleCurrentChange: function(val) {
            vue.pageIndex = val;
            vue.loadData(this.pageIndex, this.pageSize);
        },
        publicReply:function () {
            VanyAjax("receivedMessageList/addReplyToMsg?msgId="+this.msgDetail.msgId,{content:vue.content},"POST",this.$el).done(function (data) {
                vue.content="";
                vue.loadData();
            })
        },
        comfirm:function () {

            VanyAjax("receivedMessageList/comfireMsgRecord?msgId="+this.msgDetail.msgId,{},"POST",this.$el).done(function (data) {
                vue.hasConfirm="1";
            })
        }

    }

});
vue.initData();